


# to load data
library(rio)

# to process data
library(tidyverse)


# load data about laws and funds
laws <- import("list_laws.csv")
funds <- import("fund_types.csv")

#### some descriptives
# how many funds in total?
length(funds$name) # 63

# how many countries?
laws %>%
  group_by(country) %>%
  unique() %>%
  summarise(N = length(country)) # 40

# how many laws?
length(laws$doc_name) # 86


#### GENERATE FIGURE 3
figure3 <- laws %>%
  select(year) %>%
  group_by(year) %>%
  summarise(N = length(year)) %>%
  ungroup() 

ggplot(figure3, aes(x=year,y=N)) + geom_col() + 
  labs(x="Year",y="Number of legal documents") +
  theme_minimal() +
  scale_x_continuous(breaks=c(1980,1990,2000,2010,2020)) +
  scale_y_continuous(breaks=c(0,2,4,6,8,10)) + theme(axis.text.x = element_text(size=12),
                                                     axis.text.y = element_text(size=12),
                                                     axis.title.x = element_text(size=12),
                                                     axis.title.y = element_text(size=12))
ggsave("figure3.pdf", height = 5, width = 9)
